
<?php 
require 'Model.php';
class TypeModel extends Model{
	function getTypeList(){
		$sql="select * from cartoontype";		
		$data=$this->conn->query($sql);
		return $data;
	}
	function delType($tid){
		$sql="delete from cartoontype where tid=$tid";
		$result=$this->conn->query($sql);
		return $result;
	}
	function addtype($data){
			$tid=$data['tid'];
			$typename=$data['typename'];
			$sql="insert into cartoontype value($tid,'$typename')";
			$result=$this->conn->query($sql);
			return $result;

		}

	function edittype($tid){
		$sql="select * from cartoontype where tid=$tid";
		$data=$this->conn->query($sql);
		return $data;//一条数据

	}
function updatetype($data){
        $tid=$data['tid'];
        $typename=$data['typename'];
		$sql="update cartoontype set tid=$tid,typename='$typename' where tid=$tid";
			//上传头像并且根据cid更新数据
		
//如果修改了头像，需要上传新头像，否则原头像不动
       $result=$this->conn->query($sql);
		return $result;
		
	}
	function searchtype($typename){
	$key=trim($_POST['key']);
    $sql="select * from cartoontype  where (typename like'%$key%')";
    $data=$this->conn->query($sql);
	return $data;
   }








	}

 ?>	

